﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using XLua;

public class RunLua : MonoBehaviour {

    private LuaEnv luaenv;
	// Use this for initialization
	void Start () {
        luaenv = new LuaEnv();
        RunLuaByFile();

    }

    void RunLuaByString()
    {
        luaenv.DoString("print('Helloworld')");
    }

    void RunLuaByFile()
    {
        TextAsset luaFile = Resources.Load<TextAsset>("hello.lua");
        luaenv.DoString(luaFile.text);
        //通过内置loader
        luaenv.DoString("require 'hello'");
    }

    private void OnDestroy()
    {
        luaenv.Dispose();
    }
}
